home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zen & the Art of Resourc…The BMUG Guide to ResEdit
/
Zen and the Art of Resource Editing - The BMUG Guide to ResEdit (1995).iso
/
ResEdit 2.1.3
/
Examples
/
CExamples
/
Source
/
ICON.LDEF.c
next >
Wrap
C/C++ Source or Header
|
1994-07-15
|
2KB
|
64 lines
/*
COPYRIGHT (C) 1984-1990 Apple Computer,Inc.
All rights reserved
*/
#include <types.h>
#include <memory.h>
#include <menus.h>
#include <resources.h>
#include <lists.h>
#include <ToolUtils.h>
#include "ResEd.h"
#define IconSize 128
pascal void DrawIcon (Rect *lRect, Handle theIcon)
{
if (SizeResource(theIcon) >= IconSize)
PlotIcon(lRect, theIcon);
}
/* This routine simply looks up in the list at the given cell, extracts the ID and
gets the resource called for. Returns NIL if not found. Note, this assumes
the resfile is set up correctly.
NOTE: This is used by both ICON and ICN# pickers. */
Handle IconFetch (Cell lCell, ListHandle lHandle, short *id, Boolean *wasLoaded)
{
short err;
short len = 2;
Handle tempH = nil;
PickHandle tempPick;
LGetCell((Ptr)id, &len, lCell, lHandle); /* Get the ID from the list. */
if (len == 2) { /* ID must be 2 bytes. */
/* Load the resource since we want to draw it. */
tempPick = (PickHandle)((*lHandle)->refCon);
tempH = REGet1ResourceSpecial((*tempPick)->theResFile, (*tempPick)->rType, *id, wasLoaded, &err);
}
return tempH;
}
/* This is the custom drawProc for the list (which contains the resource ID's). It
simply draws the icon in the given rect and frames a selection rect around it (if
necessary). */
pascal void DrawCell(short message, Boolean lSelect, Rect *lRect, Point lCell,
short lDataOffset, short lDataLen, ListHandle lHandle)
{
Handle theIcon;
short id;
Boolean wasLoaded;
#pragma unused (lDataOffset, lDataLen) /* Not needed here. */
if ((message == lDrawMsg) || (message == lHiliteMsg)) {
theIcon = IconFetch(lCell, lHandle, &id, &wasLoaded);
DrawLDEF (message, lSelect, lRect, theIcon, id, "\p", 32, 32, DrawIcon, lHandle);
if ((theIcon != nil) && (!wasLoaded))
HPurge(theIcon);
}
}